      subroutine Mass
      use global
      Implicit none
	  integer :: ie,nelt,kloc_e(2)
	  Real(8) :: vcor_e(2), L_e,Me(2,2)
	  Me(1,:)=[ 2.D0,1.D0 ]
	  Me(2,:)=[ 1.D0,2.D0 ]
	  M=0.D0
	  
	  
	  nelt=nnt-1 ! Element numbers.
	  
	  do ie=1,nelt
	    kloc_e=[ie,ie+1]  ! the two nodes in element ie.
		vcor_e=vcor(kloc_e)  ! the coordinates of the two nodes.
		L_e=Abs(vcor_e(2)-vcor_e(1))  !Length of the element 'ie'.
		M(kloc_e,kloc_e)=M(kloc_e,kloc_e)+Me*L_e/6.D0

		!write(*,*) ie,L_e
		!write(*,*) Me(1,:)
		!write(*,*) Me(2,:)
		!write(*,*)
		!write(*,*) M(1,1)
		!write(*,*) M(2,2)
		!write(*,*) M(3,3)
		!write(*,*) M(4,4)
		!write(*,*)
	  enddo



      end subroutine